home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
CUGUK
/
UTIL_SRC
/
C016.ZIP
/
CALC
/
INIT.C
< prev
next >
Wrap
Text File
|
1990-01-19
|
2KB
|
95 lines
/* $Author: jkcohen $
* $Source: /mnt1/h/jkcohen/Source/C/Hoc/RCS/init.c,v $
* $Revision: 1.1 $ ; $Date: 87/03/16 21:18:20 $
* $State: Stab $
*/
#include "su.h"
#include "jc.h"
#include "hoc.h"
#include "ytab.h"
extern double Sqrt(), Tan(), Asin(), Acos(), Atan2(),
Exp(), Log(), Log10(), Pow(), Sinh(), Cosh(),
Gamma(), Jn(), Y0(), Y1(), Yn(), Srand(), Rand(), integer();
static struct { /* Constants */
char *name;
double cval;
} consts[] = {
"PI", 3.14159265358979323846,
"E", 2.71828182845904523536,
"GAMMA", 0.57721566490153286060, /* Euler */
"DEG", 57.29577951308232087680, /* deg/radian */
"PHI", 1.61803398874989484820, /* golden */
0, 0
};
static struct { /* Built-ins */
char *name;
double (*func)();
} bltins[] = {
"abs", fabs,
"floor", floor,
"ceil", ceil,
"sqrt", Sqrt, /* checks argument */
"sin", sin,
"cos", cos,
"tan", Tan, /* checks argument */
"asin", Asin, /* checks argument */
"acos", Acos, /* checks argument */
"atan", atan,
"exp", Exp, /* checks argument */
"log", Log, /* checks argument */
"log10", Log10, /* checks argument */
"sinh", Sinh, /* checks argument */
"cosh", Cosh, /* checks argument */
"tanh", tanh,
"gamma", Gamma, /* checks argument */
"j0", j0,
"j1", j1,
"y0", Y0, /* checks argument */
"y1", Y1, /* checks argument */
"srand", Srand, /* converts to double */
"int", integer,
0, 0
};
static struct { /* Built-ins with 2 args */
char *name;
double (*func)();
} bltins2[] = {
"hypot", hypot,
"atan2", Atan2, /* checks arguments */
"pow", Pow, /* checks arguments */
"jn", Jn, /* converts first arg to single */
"yn", Yn, /* checks arguments */
0, 0
};
static struct { /* Built-ins with 0 args */
char *name;
double (*func)();
} bltins0[] = {
"rand", Rand, /* convert to double */
0, 0
};
init() /* install constants and built-ins in table */
Begin
register int i;
register Symbol *s;
For i = 0; consts[i].name; i++ Do
install(consts[i].name, CON, consts[i].cval);
Endfor
For i = 0; bltins[i].name; i++ Do
s = install(bltins[i].name, BLTIN, 0.0);
s->u.ptr = bltins[i].func;
Endfor
For i = 0; bltins2[i].name; i++ Do
s = install(bltins2[i].name, BLTIN2, 0.0);
s->u.ptr = bltins2[i].func;
Endfor
For i = 0; bltins0[i].name; i++ Do
s = install(bltins0[i].name, BLTIN0, 0.0);
s->u.ptr = bltins0[i].func;
Endfor
End